package p.ithorns.integration.aop.hotswap;

import lombok.RequiredArgsConstructor;
import p.ithorns.framework.common.utils.CollectionUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * CompositeProxyMetaDefinitionLocator
 *
 * @author HtL
 * @date 2024/11/27 9:31
 * @since 1.0.0
 */
@RequiredArgsConstructor
public class CompositeProxyMetaDefinitionLocator implements ProxyMetaDefinitionLocator {

    private final List<ProxyMetaDefinitionLocator> delegates;

    @Override
    public List<ProxyMetaDefinition> getProxyMetaDefinitions() {
        List<ProxyMetaDefinition> compositeProxyMetaDefinitions = new ArrayList<>();
        for (ProxyMetaDefinitionLocator delegate : delegates) {
            List<ProxyMetaDefinition> proxyMetaDefinitions = delegate.getProxyMetaDefinitions();
            if(CollectionUtil.isNotEmpty(proxyMetaDefinitions)){
                compositeProxyMetaDefinitions.addAll(proxyMetaDefinitions);
            }

        }
        return compositeProxyMetaDefinitions;
    }
}